package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.ScenicSpot;
import com.ruoyi.system.service.IScenicSpotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: ZCJ
 * @date: 2024/06/24/10:10
 * @desc:
 */
@RestController
@RequestMapping("/scenic/spot")
public class ScenicSpotController extends BaseController {
    @Autowired
    private IScenicSpotService scenicSpotService;

    /**
     * 查询所有景点
     * @return
     */
    @GetMapping("/all")
    public AjaxResult getAllSpots(){
        return scenicSpotService.getAllSpots();
    }

    /**
     * 根据景点id查询景点信息
     * @param spotId
     * @return
     */
    @GetMapping("/{spotId}")
    public AjaxResult getSpotById(@PathVariable("spotId") Integer spotId){
        return scenicSpotService.getSpotById(spotId);
    }

    /**
     * 根据景点名称进行模糊匹配查询景点信息
     * @param spotName
     * @return
     */
    @GetMapping
    public TableDataInfo getSpotByName(@RequestParam("areaId") Integer areaId, @RequestParam(value = "spotName", required = false) String spotName){
        startPage();
        List<ScenicSpot> spotList = scenicSpotService.getSpotByName(areaId, spotName);
        return getDataTable(spotList);
    }

}
